package com.telecom.factory;

public class Factory {
    //静态工厂
    public static Fruit getFruit(String name)
    {
        if("apple".equals(name))
        {
            return new Apple();
        }
        else if("orange".equals(name))
        {
            return new Orange();
        }
        else
        {
            throw new RuntimeException("没有该水果");
        }
    }
}
